package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDeno5 {
    public static void main(String[] args) {
        //查询teacher
        try (Connection conn = DBUtil.getConnecting()){
            Statement statement = conn.createStatement();
            String sql="SELECT id,name,salary,title " +
            "FROM teacher ";
            ResultSet res=statement.executeQuery(sql);
            while (res.next()){
//                int id=res.getInt("id");
//                String name=res.getString("name");
//                int salary =res.getInt("salary");
//                String title=res.getString("title");
                int id=res.getInt(1);
                String name=res.getString(2);
                int salary =res.getInt(3);
                String title=res.getString(4);
                System.out.println(id+","+name+","+salary+","+title);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
